package com.dkha.server.services.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dkha.common.exception.DkException;

import com.dkha.common.modules.vo.face.FaceTrackVO;
import com.dkha.server.mappers.FaceTrackMapper;
import com.dkha.server.modules.entities.FaceTrackEntity;
import com.dkha.server.services.FaceTrackService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * 
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2020-01-10
 */
@Service
public class FaceTrackServiceImpl extends ServiceImpl<FaceTrackMapper, FaceTrackEntity> implements FaceTrackService {

    @Resource
    private FaceTrackMapper faceTrackMapper;
    @Override
    public int addFaceTrackEntity(FaceTrackEntity faceTrackEntity) {
        int count;
        try{
            count = faceTrackMapper.insert(faceTrackEntity);
    }catch (Exception e){
        throw new DkException("新增失败");
    }
        return count;
    }

    /**
     *根据摄像头和分组时间查询
     * @param idFaceCamera
     * @param packetTime
     * @return
     */
    @Override
    public List<FaceTrackEntity> querByidCameraAndTime(Long idFaceCamera, String packetTime) {
        return faceTrackMapper.querByidCameraAndTime(idFaceCamera,packetTime);
    }

    /**
     *根据摄像头Id和开始，结束时间，人脸ID
     * @param faceTrackVO
     * @return
     */
    @Override
    public List<FaceTrackEntity> queryByidCamerAndFaceId(FaceTrackVO faceTrackVO) {
        return faceTrackMapper.queryByidCamerAndFaceId(faceTrackVO);
    }

    /**
     *根据图片路径和开始，结束时间
     * @param faceTrackVO
     * @return
     */
    @Override
    public List<FaceTrackEntity> queryByurlAndTime(FaceTrackVO faceTrackVO) {
        return faceTrackMapper.queryByurlAndTime(faceTrackVO);
    }

    @Override
    public List<String> findIdFatoryByTime(FaceTrackVO faceTrackVO) {
        return faceTrackMapper.findIdFatoryByTime(faceTrackVO);
    }

    /**
     *根据图片路径和开始，结束时间和阈值
     * @param faceTrackVO
     * @return
     */
    @Override
    public List<FaceTrackEntity> queryBytrajectoryThreshold(FaceTrackVO faceTrackVO) {
        return faceTrackMapper.queryBytrajectoryThreshold(faceTrackVO);
    }

    @Override
    public List<FaceTrackEntity> findTrackByFaceId(List<String> faceIds) {
        return faceTrackMapper.findTrackByFaceId(faceIds);
    }

    @Override
    public FaceTrackEntity queryByIdPortrait(String idPortrait) {
        return faceTrackMapper.queryByIdPortrait(idPortrait);
    }
}